<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<base href="<%=basePath%>" />

		<title>My JSP 'tab.jsp' starting page</title>

		<meta http-equiv="pragma" content="no-cache"/>
		<meta http-equiv="cache-control" content="no-cache"/>
		<meta http-equiv="expires" content="0"/>
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3"/>
		<meta http-equiv="description" content="This is my page"/>
		<SCRIPT src="js/color.js" type="text/javascript"></SCRIPT>
		<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}

.STYLE1 {
	font-size: 12px
}

.STYLE3 {
	font-size: 12px;
	font-weight: bold;
}

.STYLE4 {
	color: #03515d;
	font-size: 12px;
}

-->
.boxBorder {
	border: 1px solid green;
}

#addlink,#addlinks {
	position: absolute;
	width: 400px;
	left: 50%;
	top: 50%;
	margin-left: -200px;
	height: auto;
	z-index: 100;
	background-color: #fff;
	border: 1px #8FA4F5 solid;
	padding: 1px;
}

#addlink h2,#addlinks h2 {
	height: 25px;
	font-size: 14px;
	background-color: #7bc4d3;
	position: relative;
	padding-left: 10px;
	line-height: 25px;
	color: white;
}

#addlink h2 a ,#addlinks h2 a{
	position: absolute;
	right: 5px;
	font-size: 12px;
	color: white;
}
#addlink .ywinfo ,#addlinks .addyw{
	padding-left: 10px;
}
#BgDiv ,#BgDivs{
	background-color: #e3e3e3;
	position: absolute;
	z-index: 99;
	left: 0;
	top: 0;
	display: none;
	width: 100%;
	height: 1000px;
	opacity: 0.5;
	filter: alpha(opacity = 50);
	-moz-opacity: 0.5;
}
</style>
		<SCRIPT src="js/jquery.js" type="text/javascript"></SCRIPT>
		<script type="text/javascript">
	function edit(mid,medicinename,jiage,jianjie){
			addlink.style.display="block";
			addlink.style.top="130px";
			addlink.style.left="350px";
			BgDiv.style.display="block";
			$("#edit").css("display","block");
			$("#medicine").val(medicinename);
			$("#mid").val(mid);
			$("#ywjiage").val(jiage);
			$("#ywjianjie").val(jianjie);
	}
	
	function closeMe(){
			BgDiv.style.display="none";
	 		$("#edit").css("display","none");
		}
	
	function addmed(){
		addlinks.style.display="block";
			addlinks.style.top="130px";
			addlinks.style.left="350px";
			BgDivs.style.display="block";
			$("#edits").css("display","block");
	}
	
	function closeMes(){
			BgDivs.style.display="none";
	 		$("#edits").css("display","none");
		}
		
		
		function doCheck(){
                        var medicine = document.AddForm.medicine.value;   
                        var mprix = document.AddForm.mprix.value;   
                        var msynopsis = document.AddForm.msynopsis.value;   
                        if(medicine==""){
	                        alert("药物不能为空!");
	                        return false;
                        }
                        
                         if(mprix==""){
	                        alert("价格不能为空！");
	                        return false;
                        }
                        
                         if(msynopsis==""){
	                        alert("介绍不能为空！");
	                        return false;
                        }
                        
                         return true;
                     }
</script>

	</head>
	<body>
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td height="30" background="backstage/tab/images//tab_05.gif">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td width="12" height="30">
								<img src="backstage/tab/images//tab_03.gif" width="12"
									height="30" />
							</td>
							<td>
								<table width="100%" border="0" cellspacing="0" cellpadding="0">
									<tr>
										<td width="46%" valign="middle">
											<table width="100%" border="0" cellspacing="0"
												cellpadding="0">
												<tr>
													<td width="5%">
														<div align="center">
															<img src="backstage/tab/images//tb.gif" width="16"
																height="16" />
														</div>
													</td>
													<td width="95%" class="STYLE1">
														<span class="STYLE3">你当前的位置</span>：[业务中心]-[药物查询]
													</td>
												</tr>
											</table>
										</td>
										<td width="54%">
											<table border="0" align="right" cellpadding="0"
												cellspacing="0">
												<tr>
													<td width="120">
														<table width="90%" border="0" cellpadding="0"
															cellspacing="0">
															<tr>
																<td class="STYLE1" colspan="2">
																	<div align="center">
																		<a onclick="addmed()"><span style="cursor:pointer;">【新增】</span></a>
																	</div>
																</td>
															</tr>
														</table>
													</td>
													<td width="280">
														<table width="90%" border="0" cellpadding="0"
															cellspacing="0">
															<tr>
																<td class="STYLE1" colspan="2">
																	<div align="center">
																		<form
																			action="medicine.do?method=showtypeMedicine&admin=ly"
																			method="post">
																			查看方式
																			<select name="fx" id="fx">
																				<option value="0">
																					全部
																				</option>
																				<option value="1">
																					西药
																				</option>
																				<option value="2">
																					中成药
																				</option>
																				<option value="3">
																					中药
																				</option>
																			</select>
																			<input type="submit" style="font-size: 10px"
																				value="查询" />
																		</form>
																	</div>
																</td>
															</tr>
														</table>
													</td>
													<td width="300">
														<table width="88%" border="0" cellpadding="0"
															cellspacing="0">
															<tr>
																<td class="STYLE1" colspan="2">
																	<form action="medicine.do?method=getMedicine&admin=ly"
																		method="post">
																		药物名
																		<input type="text" name="medicinename" size="10" />
																		<input type="submit" style="font-size: 10px"
																			value="查询" />
																	</form>
																</td>
															</tr>
														</table>
													</td>
												</tr>
											</table>
										</td>
									</tr>
								</table>
							</td>
							<td width="16">
								<img src="backstage/tab/images//tab_07.gif" width="16"
									height="30" />
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
				<c:if test="${message != null}">
								<table width="100%">
									<tr style="background-color: #87CEFF">
										<td align="center" valign="center" height="30">
											<div>${message}</div>
										</td>
									</tr>
								</table>
							</c:if>
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td width="8" background="backstage/tab/images//tab_12.gif">
								&nbsp;
							</td>
							<td>
								<table width="100%" border="0" cellpadding="0" cellspacing="1"
									bgcolor="b5d6e6" onmouseover="changeto()" onmouseout="changeback()">
									<tr>
										<td width="10%" height="22"
											background="backstage/tab/images//bg.gif" bgcolor="#FFFFFF">
											<div align="center">
												<span class="STYLE1">药物名</span>
											</div>
										</td>
										<td width="10%" height="22"
											background="backstage/tab/images//bg.gif" bgcolor="#FFFFFF">
											<div align="center">
												<span class="STYLE1">类型</span>
											</div>
										</td>
										<td width="10%" height="22"
											background="backstage/tab/images//bg.gif" bgcolor="#FFFFFF">
											<div align="center">
												<span class="STYLE1">价格</span>
											</div>
										</td>
										<td width="10%" height="22"
											background="backstage/tab/images//bg.gif" bgcolor="#FFFFFF">
											<div align="center">
												<span class="STYLE1">药物简介</span>
											</div>
										</td>
										<td width="15%" height="22"
											background="backstage/tab/images//bg.gif" bgcolor="#FFFFFF"
											class="STYLE1">
											<div align="center">
												基本操作
											</div>
										</td>
									</tr>
									<c:forEach items="${allMedicine}" var="sa">
										<tr>
											<td width="10%" height="22"
												 bgcolor="#FFFFFF">
												<div align="center">
													<span class="STYLE1">${sa.medicine}</span>
												</div>
											</td>
											<td width="10%" height="22"
												 bgcolor="#FFFFFF">
												<div align="center">
													<c:choose>
														<c:when test="${sa.mtype == 1}">
															<span class="STYLE1">西药</span>
														</c:when>
														<c:when test="${sa.mtype == 2}">
															<span class="STYLE1">中成药</span>
														</c:when>
														<c:otherwise>
															<span class="STYLE1">中药</span>
														</c:otherwise>
													</c:choose>

												</div>
											</td>
											<td width="10%" height="22"
												 bgcolor="#FFFFFF">
												<div align="center">
													<span class="STYLE1">${sa.mprix}</span>
												</div>
											</td>
											<td width="10%" height="22"
												 bgcolor="#FFFFFF">
												<div align="center">
													<span class="STYLE1">${sa.msynopsis}</span>
												</div>
											</td>
											<td width="15%" height="22"
												 bgcolor="#FFFFFF"
												class="STYLE1">
												<div align="center">
												<img src="backstage/tab/images//edt.gif" width="16" height="16" />
													<a onclick="edit(${sa.mid},'${sa.medicine}','${sa.mprix}','${sa.msynopsis}')"><span style="cursor:pointer;">编辑</span></a>||
													<img src="backstage/tab/images//del.gif" width="16" height="16" />
													<a href="medicine.do?method=delMedicine&mdid=${sa.mid}" onclick="return confirm('确定删除该药品？');">删除</a>
												</div>
											</td>
										</tr>
									</c:forEach>
								</table>
							<td width="8"
								background="backstage/tab/backstage/tab/images///tab_15.gif">
								&nbsp;
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td height="35"
					background="backstage/tab/backstage/tab/images///tab_19.gif">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td width="12" height="35">
								<img src="backstage/tab/images/tab_18.gif" width="12"
									height="35" />
							</td>
							<td>
							<c:if test="${fx!=null}">
								<table width="100%" border="0" cellspacing="0" cellpadding="0">
									<tr>
										<td class="STYLE4">
											&nbsp;&nbsp;共有 ${rowCount} 条记录，当前第 ${current}/${pageCount} 页
										</td>
										<td>
										<form action="medicine.do?method=showtypeMedicine&fx=${fx}&admin=ly" method="post">
											<table border="0" align="right" cellpadding="0"
												cellspacing="0">
												<tr>
													<td width="40">
													<a href="medicine.do?method=showtypeMedicine&fx=${fx}&admin=ly&current=1">
														<img src="backstage/tab/images/first.gif" width="37" height="15" border="0"/>
														</a>
													</td>
													<td width="45">
													<a href="medicine.do?method=showtypeMedicine&fx=${fx}&admin=ly&current=${current-1}">
														<img src="backstage/tab/images/back.gif" width="43" height="15" border="0"/>
														</a>
													</td>
													<td width="45">
													<a href="medicine.do?method=showtypeMedicine&fx=${fx}&admin=ly&current=${current+1}">
														<img src="backstage/tab/images/next.gif" width="43" height="15" border="0"/>
														</a>
													</td>
													<td width="40">
													<a href="medicine.do?method=showtypeMedicine&fx=${fx}&admin=ly&current=${pageCount}">
														<img src="backstage/tab/images/last.gif" width="37" height="15" border="0"/>
														</a>
													</td>
													
													<td width="100">
														<div align="center">
															<span class="STYLE1">转到第 <input name="current"
																	type="text" size="4"
																	onkeypress="if ((event.keyCode<48 || event.keyCode>57)) {event.returnValue=false};
															if(this.value.length > 4){this.value = 10000}"
																	style="height: 12px; width: 20px; border: 1px solid #999999;" />
																页 </span>
														</div>
													</td>
													<td width="40">
														<img src="backstage/tab/images/go.gif" width="37" height="15" onclick="submit()"/>
													</td>
												</tr>
											</table>
											</form>
										</td>
									</tr>
								</table>
								</c:if>
								<c:if test="${medicinename!=null}">
								<table width="100%" border="0" cellspacing="0" cellpadding="0">
									<tr>
										<td class="STYLE4">
											&nbsp;&nbsp;共有 ${rowCount} 条记录，当前第 ${current}/${pageCount} 页
										</td>
										<td>
										<form action="medicine.do?method=getMedicine&medicinename=${medicinename}&admin=ly" method="post">
											<table border="0" align="right" cellpadding="0"
												cellspacing="0">
												<tr>
													<td width="40">
													<a href="medicine.do?method=getMedicine&medicinename=${medicinename}&admin=ly&current=1">
														<img src="backstage/tab/images/first.gif" width="37" height="15" border="0"/>
														</a>
													</td>
													<td width="45">
													<a href="medicine.do?method=getMedicine&medicinename=${medicinename}&admin=ly&current=${current-1}">
														<img src="backstage/tab/images/back.gif" width="43" height="15" border="0"/>
														</a>
													</td>
													<td width="45">
													<a href="medicine.do?method=getMedicine&medicinename=${medicinename}&admin=ly&current=${current+1}">
														<img src="backstage/tab/images/next.gif" width="43" height="15" border="0"/>
														</a>
													</td>
													<td width="40">
													<a href="medicine.do?method=getMedicine&medicinename=${medicinename}&admin=ly&current=${pageCount}">
														<img src="backstage/tab/images/last.gif" width="37" height="15" border="0"/>
														</a>
													</td>
													
													<td width="100">
														<div align="center">
															<span class="STYLE1">转到第 <input name="current"
																	type="text" size="4"
																	onkeypress="if ((event.keyCode<48 || event.keyCode>57)) {event.returnValue=false};
															if(this.value.length > 4){this.value = 10000}"
																	style="height: 12px; width: 20px; border: 1px solid #999999;" />
																页 </span>
														</div>
													</td>
													<td width="40">
														<img src="backstage/tab/images/go.gif" width="37" height="15" onclick="submit()"/>
													</td>
												</tr>
											</table>
											</form>
										</td>
									</tr>
								</table>
								</c:if>
							</td>
							<td width="16">
								<img src="backstage/tab/images/tab_20.gif" width="16"
									height="35" />
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		
		<div id="BgDiv"></div>
				<div  id="edit" style="display: none">
    <div id="addlink" style="width:423px;height:220px;margin:0px auto 0px;padding:1px;border:1px solid #a5b6c8;background-color:#eef3f7;">
    <h2 id="bianji">
					药物编辑
				<a href="javascript: closeMe( )">关闭</a>
			</h2>
		<div id="ywinfo">
							<form action="medicine.do?method=updateMedicine" method="post">
								<input id="mid" name="mid" type="hidden" />
								&nbsp;&nbsp;&nbsp;药物名:&nbsp;&nbsp;&nbsp;
								<input type="text" readonly="readonly" id="medicine"
									name="medicine" />
								<br />
								<br />
								&nbsp;&nbsp;&nbsp;价&nbsp;&nbsp;&nbsp; 格:&nbsp;&nbsp;&nbsp;
								<input type="text" name="mprix" id="ywjiage"/>
								<br />
								<br />
								&nbsp;&nbsp;&nbsp;介&nbsp;&nbsp;&nbsp; 绍:&nbsp;&nbsp;&nbsp;
								<input type="text" name="msynopsis" id="ywjianjie" />
								<br />
								<br />
								&nbsp;&nbsp;&nbsp;类&nbsp;&nbsp;&nbsp; 型:&nbsp;&nbsp;&nbsp;
								<select name="mtype">
									<option value="1">
										西药
									</option>
									<option value="2">
										中成药
									</option>
									<option value="3">
										中药
									</option>
								</select>
								<center><input type="submit" value="提交" /></center>
							</form>
    </div>
    </div>
    </div>
    
    <div id="BgDivs"></div>
				<div  id="edits" style="display: none">
    <div id="addlinks" style="width:423px;height:220px;margin:0px auto 0px;padding:1px;border:1px solid #a5b6c8;background-color:#eef3f7;">
    <h2 id="bianji">
					新增药物
				<a href="javascript: closeMes( )">关闭</a>
			</h2>
   				 <div id="addyw">
							<center>
								<form action="medicine.do?method=addMedicine" method="post" name="AddForm">
									&nbsp;&nbsp;&nbsp;药物名:&nbsp;&nbsp;&nbsp;
									<input type="text" name="medicine" />
									<br />
									&nbsp;&nbsp;&nbsp;价&nbsp;&nbsp;&nbsp; 格:&nbsp;&nbsp;&nbsp;
									<input type="text" name="mprix" />
									<br />
									&nbsp;&nbsp;&nbsp;介&nbsp;&nbsp;&nbsp; 绍:&nbsp;&nbsp;&nbsp;
									<input type="text" name="msynopsis" />
									<br />
									类&nbsp;&nbsp;&nbsp; 型:&nbsp;&nbsp;&nbsp;
									<select name="mtype">
										<option value="1">
											西药
										</option>
										<option value="2">
											中成药
										</option>
										<option value="3">
											中药
										</option>
									</select>
									<center>
									<input type="submit" value="提交"  onclick="return doCheck()" /></center>
								</form>
							</center>
						</div>
	</body>
</html>
